<?php
	// Книжная лавка 
	include_once('misc.php');
	
	
	$login = auth();
	$books = get_books();
	//print_r($books);
?>
<!DOCTYPE html> <!-- HTML 5.0 -->
<html>
	<head>
		<meta http-equiv="Content-Type" 
					content="text/html; charset=utf-8"/>
		<title>Книжная лавка</title>
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	<body>
		<div class="container">
		<!-- Header -->
		<div class="header">
			<img class="logo" width="200" height="200" alt="logo" 
						src="img/logo.png"/>
			<ul>
				<li><a href="cart.php">Корзина</a></li>
				<?php if($_SESSION['login']) { ?>
				<li><a href="logout.php">Выйти</a></li>
				<? } else { ?>
				<li><a href="reg.php">Регистрация</a></li>
				<form action="login.php" method="POST">
					<input type="textfield" name="login"/>
					<input type="password" name="pass"/>
					<input type="submit" value="Войти"/>
				</form>
				<? } ?>
			</ul>
			<div class="clear"></div>
		</div>
		<!-- Список книг -->
		<div class="main">
			<?php foreach($books as $book) { ?>
			<div class="book">
				<img class="book_img" width="100" height="100" 
					alt="<?=iconv("cp866", "utf-8", $book['title'])?>" 
					src="img/books/<?=$book['id']?>.png"/>
				<h2><?=iconv("cp866", "utf-8", $book['title'])?></h2>
				цена:<span class="price"><?=$book['price']?></span>
				<a href="add_cart.php?id=<?=$book['id']?>">
					<img class="add_cart" width="50" height="50"
						alt="в корзину"/></a>
				<div class="clear"></div>
			</div>
			<? } ?>
		</div>
		<!-- footer -->
		<div class="footer">
			CC-BY PM 2012
		</div>
		</div>
	</body>
</html>
	
						
		

	